﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Extensions.Localization;
using Thinker.SignChannel.Localization;
using Volo.Abp.DependencyInjection;

namespace Thinker.SignChannel.Excels;

public class LocalizationTranslator(IStringLocalizer<SignChannelResource> localizer)
    : IExcelTranslator, ITransientDependency
{
    public virtual IEnumerable<TranslateItem> GetItems(Type type)
    {
        var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
        foreach (var property in properties)
        {
            if (property is { CanRead: true, CanWrite: true })
            {
                yield return new TranslateItem(property.Name, localizer[property.Name]);
            }
        }
    }
}